package com.monkey.luffer.springboot.demo.basis.kcc.test.majiang;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author jiahong.liu
 */
@Data
public class PlayerHand {
    int cardNum = 0;
    List<Integer> all = new ArrayList<>();

    List<Integer> jiang = new ArrayList<>();
    List<Integer> kez = new ArrayList<>();

    public void putInCard(Majiang.Card card) {
        cardNum++;
        all.add(card.getSuit().getSalt() + card.getNumber());
        Collections.sort(all);
    }

    public void removeCard(Majiang.Card card) {
        cardNum--;
        all.remove(Integer.valueOf(card.getSuit().getSalt() + card.getNumber()));
        Collections.sort(all);
    }


    public void removeCard(Integer card) {
        cardNum--;
        all.remove(card);
        Collections.sort(all);
    }

    public void removeCard(int card) {
        cardNum--;
        all.remove(card);
        Collections.sort(all);
    }

    public String printCard() {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < this.all.size(); i++) {
            sb.append(Majiang.Card.getCard(all.get(i)).printCard()).append(" ");
        }
        return sb.toString();
    }

    public boolean hasCard(Majiang.Card card) {
        return all.contains(card.getSuit().getSalt() + card.getNumber());
    }

}
